#version 400

layout(location=0) in vec4 in_Position;
layout(location=1) in vec4 in_Color;
layout(location=2) in vec4 in_Normal;

//uniform mat4 mModelMatrix;
//uniform mat4 mViewMatrix;
//uniform mat4 mProjectionMatrix;
uniform mat4 mModelViewMatrix;
uniform mat4 mProjectionMatrix;
uniform vec4 vLightDirInCamSpace;

out vec4 ex_Color;

void main(void) 
{
	//vec4	vLightDirection	= vec4( 1.0, -1.0, 0.0, 0.0 );
	float	fLightIntensity		= 1.0f;
	float	fAmbientIntensity	= 0.2f;

	gl_Position	= mProjectionMatrix * mModelViewMatrix * in_Position;

	vec4 vNormalInCamSpace		= mModelViewMatrix * in_Normal;
	//vec4 vTransformedLightDir	= mModelViewMatrix * normalize( vLightDirection );

	float cosAngIncidence = dot( vNormalInCamSpace, normalize( vLightDirInCamSpace ) );
    cosAngIncidence = clamp( cosAngIncidence, 0.0, 1.0 );
    
    ex_Color = fLightIntensity * in_Color * cosAngIncidence + fAmbientIntensity * in_Color;
	//ex_Color	= in_Color;
}
